﻿@{
    Layout = "~/Views/Shared/_WxLayout.cshtml";
    ViewBag.Title = "图文类题目";
}
<div class="weui-gallery" style="display: block;">
    @for (int i = 1; i <= 12; i++)
    {
        var url = $"/imgs/pmp/{i}.png";
        <span class="weui-gallery__img" style='background-image: url("@url")'></span>
    }
    <div class="weui-gallery__opr">
        <a href="javascript:" class="weui-btn weui-btn_mini weui-btn_default" onclick="last()">上一张</a>
        <a href="@Url.Action("PicList") " class="weui-btn weui-btn_mini weui-btn_default">返回</a>
        <a href="javascript:" class="weui-btn weui-btn_mini weui-btn_default" onclick="next()">下一张</a>
    </div>
</div>

<script>
    $(document).ready(function () {
        $("span").each(function (i, ele) {
            $(ele).hide();
        }).eq(0).show().attr("curr", 1);
    });
    function last() {
        let spans = $("span[curr=1]").prev("span");
        if (spans.length > 0) {
            $("span").hide().removeAttr("curr");
            spans.eq(0).show().attr("curr", 1);
        } else {
            layer.open({
                time: 2
                , shade: false
                , style: 'background-color: #666;color:#fff; border:none;'
                , content: '没有上一张了'
            });
        }
    }
    function next() {
        let spans = $("span[curr=1]").next("span");
        if (spans.length > 0) {
            $("span").hide().removeAttr("curr");
            spans.eq(0).show().attr("curr", 1);
        } else {
            layer.open({
                time: 2
                , shade: false
                , style: 'background-color: #666;color:#fff; border:none;'
                , content: '没有下一张了'
            });
        }
    }

</script>